import React, { useEffect } from 'react';

const Consumlist = () => {
    let navigate = React.router.useNavigate();
    const [LoginUser, setLoginUser] = React.useState(React.$cookie.load('LoginUser') ?? {})
    const [consumlist, setConsumlist] = React.useState([])
    useEffect(() => {
        getConsumlist();
    }, [])

    const getConsumlist = async () => {
        let result = await React.$api.consum({
            busid: LoginUser.id
        })
        if (result.code == 1) {
            console.log(result.data)
            setConsumlist(result.data)
        }
    }
    return (
        <>
            <React.$vant.NavBar
                title="消费记录"
                leftText=""
                onClickLeft={() => navigate('/business/index')}
            />
            {
                consumlist.map((item) => {
                    return (
                        <div className="item"  style={{ width: '85%',margin: 'auto',marginTop: '10px', paddingBottom: '10px',borderBottom: '1px solid #ccc',display:'flex',justifyContent: 'space-around', alignItems: 'center'}} >
                            <div className="left" style={{fontSize: '14px',    width: '250px'}}>{ item.content }</div>
                            <div className="right"style={{    color: '#ccc',marginLeft:'30px'}}>{item.createtime }</div>
                        </div>
                    )
                })
            }

        </>
    )

}

export default Consumlist;